﻿using System.Collections.Generic;
using System.Data.Services.Common;
using System.Linq;

namespace DataServiceInterception
{
    // Expose list of customers Customer as IQueryable
    public class CustomerService
    {
        private List<Customer> _List = new List<Customer>();

        public CustomerService()
        {

            _List.Add(new Customer() { ID = 1, Code = "AAA", Name = "A1" });
            _List.Add(new Customer() { ID = 2, Code = "BBB", Name = "BStore" });
            _List.Add(new Customer() { ID = 3, Code = "CCC", Name = "CStore" });
        }

        public IQueryable<Customer> Customers
        {
            get
            {
                return _List.AsQueryable<Customer>();
            }
        }

    }


    // Entity to expose in atom:Entry
    [DataServiceKey("ID")]
    public class Customer
    {
        public int ID { get; set; }  // ID is required to be a viable OData entity
        public string Code { get; set; }
        public string Name { get; set; }
    }

}